More rows for one record
Hello,
I have MyTable with two fields - Item and Number of pieces
Example :
Item1 - 5 pcs
Item2 - 1 pc
Item3 - 3 pcs
...
I want print for each record more rows (row count is equal as number of pieces).
Example :
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item2 - 1 pc
Item3 - 3 pcs
Item3 - 3 pcs
Item3 - 3 pcs
...
I solved it in this way :
var
ds: TfrxDataSet;
Count:integer;
IsFirst:boolean;
procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
begin
if IsFirst then ds.Prior;
end;
procedure DetailData1OnAfterPrint(Sender: TfrxComponent);
begin
Inc(Count); IsFirst:=False;
if (Count < <MyTable."Pieces"> ) then begin
if ds.RecNo=0 then IsFirst:=True
else ds.Prior;
end else begin
Count:=0;
end;
end;
begin
ds := Report.GetDataset('MyTable');
Count:=0;
First:=False;
end.
It is working, but problem occurs if in MyTable is only one record. I think that problem is in function ds.Prior. If we are on first record and call ds.Prior, FastReport do not set it to BOF, but ignore it ...
Have you any ideas as solve it ?
Thanks !
I have MyTable with two fields - Item and Number of pieces
Example :
Item1 - 5 pcs
Item2 - 1 pc
Item3 - 3 pcs
...
I want print for each record more rows (row count is equal as number of pieces).
Example :
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item1 - 5 pcs
Item2 - 1 pc
Item3 - 3 pcs
Item3 - 3 pcs
Item3 - 3 pcs
...
I solved it in this way :
var
ds: TfrxDataSet;
Count:integer;
IsFirst:boolean;
procedure DetailData1OnBeforePrint(Sender: TfrxComponent);
begin
if IsFirst then ds.Prior;
end;
procedure DetailData1OnAfterPrint(Sender: TfrxComponent);
begin
Inc(Count); IsFirst:=False;
if (Count < <MyTable."Pieces"> ) then begin
if ds.RecNo=0 then IsFirst:=True
else ds.Prior;
end else begin
Count:=0;
end;
end;
begin
ds := Report.GetDataset('MyTable');
Count:=0;
First:=False;
end.
It is working, but problem occurs if in MyTable is only one record. I think that problem is in function ds.Prior. If we are on first record and call ds.Prior, FastReport do not set it to BOF, but ignore it ...
Have you any ideas as solve it ?
Thanks !
Comments
i would create an unattached child band duplicating the memos of the mdband
in the obp event of the master write code to populate the child memos if the number of pieces is>1
set an index variable to number of pieces minus 1
then in the oap event call the engine .showband(name of childband);
in a while loop.
do not connect the band to a dataset, in the obp event of the detail data
write code to set the visibility and rowcount prop of the subdetail band.
ie
if <MyTable."Pieces"> >1 then
begin
subdetail1.visible := true;
subdetail1.rowcount := <MyTable."Pieces">-1;
end
else subdetail1.visible := false;
end;
Thank you very much for good tip ! It is working.
But I did it easier more - I keep DetailBand empty, all memos copy to SubdetailBand and into OnBeforePrint of DetailBand I put only :
Subdetail1.rowcount := <MyTable."Pieces">